<template>
  <div
    class="bordered-avatar justify-center items-center"
    @mouseover="onOver"
    @mouseout="onOut"
    :style="`width:${width};height:${height}`"
  >
    <q-img class="image" :src="src" v-if="src"></q-img>
    <q-icon
      class="icon"
      :name="icon"
      :color="iconColor"
      :style="`font-size:${iconSize}`"
      v-else
    />
    <transition name="fade">
      <div class="more-cover fit fade no-pointer-events" v-show="more">
        <slot name="hover-cover"></slot>
      </div>
    </transition>
  </div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
  props: {
    src: String,
    icon: String,
    isIcon: Boolean,
    iconColor: String,
    iconSize: String,
    width: String,
    height: String,
  },
  setup(_, { emit }) {
    const more = ref(false);
    return {
      more,
      onOver() {
        more.value = true;
        emit('onOver');
      },
      onOut() {
        more.value = false;
        emit('onOut');
      },
    };
  },
});
</script>
<style lang="scss" scoped>
.bordered-avatar {
  border-radius: 50%;
  background-color: #242424;
  position: relative;
  display: flex;
  .image {
    position: absolute;
    width: 90%;
    height: 90%;
    border-radius: 50%;
  }
  .icon {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }
  .more-cover {
    background-color: rgba(16, 16, 16, 0.6);
    position: absolute;
  }
}
.fade-enter-active {
  animation: fade 0.5s;
}
.fade-leave-active {
  animation: fade 0.5s reverse;
}
@keyframes fade {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
</style>